<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="author" content="wyh">
        <title></title>
        <style>
            
        </style>
    </head>
    <body>
        <p id="latitude">纬度</p>    
        <p id="longitude">经度</p>
    </body>
    <script>
        var lat =document.getElementById("latitude");
        var lon =document.getElementById("longitude");
        // console.log(navigator.geolocation);
        navigator.geolocation.getCurrentPosition(function(position){
            console.log(position);
            lat.innerHTML =position.coords.latitude;
            lon.innerHTML =position.coords.longitude;
        })
    </script>
<html>